import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayAppVO, PayAppForm, PayAppQuery } from './types';

/**
 * 查询应用列列表
 * @param query
 * @returns {*}
 */
export const listPayApp = (query?: PayAppQuery): AxiosPromise<PayAppVO[]> => {
  return request({
    url: '/system/PayApp/list',
    method: 'get',
    params: query,
    headers: {
      repeatSubmit: false
    }
  });
};

/**
 * 查询应用列列表
 * @param query
 * @returns {*}
 */
export const queryListPayApp = (query?: PayAppQuery): AxiosPromise<PayAppVO[]> => {
  return request({
    url: '/system/PayApp/queryList',
    method: 'get',
    params: query,
    headers: {
      repeatSubmit: false
    }
  });
};

/**
 * ### 修改应用备注
 * @param query
 */
export const setRemark = (data) => {
  return request({
    url: '/system/PayApp/remark',
    method: 'post',
    data
  });
};

/**
 * 查询应用收款统计
 */
export const getPayCahrtApp = (appIds: Array<number | string>) => {
  return request({
    url: '/system/PayChart/app',
    method: 'post',
    data: {
      appIds
    }
  });
};

/**
 * 查询应用列详细
 * @param appId
 */
export const getPayApp = (appId: string | number): AxiosPromise<PayAppVO> => {
  return request({
    url: '/system/PayApp/' + appId,
    method: 'get'
  });
};

/**
 * 新增应用列
 * @param data
 */
export const addPayApp = (data: PayAppForm) => {
  return request({
    url: '/system/PayApp',
    method: 'post',
    data: data
  });
};

/**
 * 修改应用列
 * @param data
 */
export const updatePayApp = (data: PayAppForm) => {
  return request({
    url: '/system/PayApp',
    method: 'put',
    data: data
  });
};

// 更新应用吃单比例
export const updatePayAppRatio = (data: PayAppForm) => {
  return request({
    url: '/system/PayApp/updateRatio',
    method: 'put',
    data: data
  });
};

/**
 * 删除应用列
 * @param appId
 */
export const delPayApp = (appId: string | number | Array<string | number>) => {
  return request({
    url: '/system/PayApp/' + appId,
    method: 'delete'
  });
};

export const getCurrency = () => {
  return request({
    url: 'system/PayRate/selectList',
    method: 'get'
  });
};

//查询商户列表
export const getClient = (params) => {
  return request({
    url: 'system/user/selectList',
    params: params,
    method: 'get'
  });
};

//不分页查询风控策略列表
export const getPayPolicy = (params) => {
  return request({
    url: 'system/PayPolicy/selectList',
    method: 'get',
    params
  });
};